package com.ophiux.micro.core.application;

import com.ophiux.utils.common.StringUtil;

/**
 * 分页查询基础请求入参
 * 2018-10-24 chenh
 * @author chenh
 *
 */
public class PageRequestDTO<T> extends RequestDTO {

	public String PAGE_INDEX;	//页标
	
	public String PAGE_SIZE;	//页面大小
	
	public T QUERY_PREDICATE;	//查询相关条件

	public String getPAGE_INDEX() {
		return PAGE_INDEX;
	}

	public void setPAGE_INDEX(String pAGE_INDEX) {
		PAGE_INDEX = pAGE_INDEX;
	}

	public String getPAGE_SIZE() {
		return PAGE_SIZE;
	}

	public void setPAGE_SIZE(String pAGE_SIZE) {
		PAGE_SIZE = pAGE_SIZE;
	}

	public T getQUERY_PREDICATE() {
		return QUERY_PREDICATE;
	}

	public void setQUERY_PREDICATE(T qUERY_PREDICATE) {
		QUERY_PREDICATE = qUERY_PREDICATE;
	}

	@Override
	public boolean isParamValid() {
		if(StringUtil.isEmpty(PAGE_INDEX)
				|| StringUtil.isEmpty(PAGE_SIZE)) {
			return false;
		}
		if(QUERY_PREDICATE instanceof RequestDTO && RequestDTO.class.isAssignableFrom(QUERY_PREDICATE.getClass())) {
			if(!((RequestDTO)QUERY_PREDICATE).isParamValid()) {
				return false;
			}
		}
		return true;
	}

	
}
